"""
    DatabaseAbstraction.py - A layer to interact with a given database
    Copyright (C) 2010  Matthew Baldwin <secretagentcook@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>
"""
import dbAccess
import FlatFile
class Main(object):
    '''
    This is the class that should be called by all other modules for database
    interaction.
    '''

    def __init__(self):
        pass

    def player_write(self, db_type,  name,  password):
        self.db_type = db_type
        self.name = name
        self.password = password
        
        if self.db_type == 'file':
            FlatFile.FAccess.fWrite('player',  self.name,  self.password)
            
        elif self.db_type == 'sql':
            pass
            
    def player_read(self,  db_type,  name):
        self.db_type = db_type
        self.name = name
        self.database = 'player' # this is just a place holder.  different code will be added to handle all databases
        print "In player_read!!"
        if self.db_type == 'file':
            self.results = FlatFile.FAccess.fRead(self.database, self.name)
            print self.results
            return self.results
           

Main = Main()
